using System.Collections.Generic;
using Infrastructure.Events.Interfaces;
using VirtuosoDal;
using VirtuosoDal.Entities;

namespace AspNetMvc.Helpers
{
    public class AdditionalPropertiesHelper
    {
        public static Dictionary<EventPropertyDescription, List<string>> FillAdditionalPropertyWithValues(IEventPropertyDescriptionManager _eventPropertyDescriptionManager,
            string uri, Dictionary<string, List<string>> values, string language)
        {
            var propertiesWithValues = new Dictionary<EventPropertyDescription, List<string>>();

            List<string> additionalProperties;
            if (EventsConfigManager.TryGetAdditionalProperties(uri, out additionalProperties))
            {
                foreach (var additionalProperty in additionalProperties)
                {
                    var additionalPropertyDescription = _eventPropertyDescriptionManager.GetEventPropertyDescription(additionalProperty, language);

                    //We need one empty item
                    //ToDo: Looks ugly - reimplement
                    if (values != null && values.ContainsKey(additionalProperty))
                    propertiesWithValues[additionalPropertyDescription] = values[additionalProperty];
                    else
                        propertiesWithValues[additionalPropertyDescription] = new List<string>() { "" };
                }
            }

            return propertiesWithValues;
        }
    }
}